<template>
  <el-dialog title="编辑" :visible.sync="open" width="1200px" append-to-body :before-close="close">
    <el-form ref="form" :model="form" label-position="left" label-width="130px">
      <el-divider content-position="center">基本信息</el-divider>
      <el-row>
        <el-col :span="8">
          <el-form-item label="账册备案料号" prop="record_material_no">
            <el-input v-model="form.record_material_no" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="条形码" prop="barcode">
            <el-input v-model="form.barcode" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="海关编码" prop="g_code">
            <el-input v-model="form.g_code" maxlength="50" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="海关备案品名" prop="g_name">
            <el-input v-model="form.g_name" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="商品规格" prop="g_model">
            <el-input v-model="form.g_model" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="原产国" prop="origin_country_code">
            <el-select v-model="form.origin_country_code" placeholder="请选择原产国">
              <el-option v-for="(itme,index) in tradeCountry" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="贸易国" prop="trade_country_code">
            <el-select v-model="form.trade_country_code" placeholder="请选择贸易国">
              <el-option v-for="(itme,index) in tradeCountry" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="币制" prop="currency_code">
            <el-select v-model="form.currency_code" placeholder="请选择币制">
              <el-option v-for="(itme,index) in currency" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="计量单位" prop="unit">
            <el-select v-model="form.unit" placeholder="计量单位">
              <el-option v-for="(itme,index) in unit_code" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="法定计量单位" prop="unit1">
            <el-select v-model="form.unit1" placeholder="法定计量单位编码">
              <el-option v-for="(itme,index) in unit_code" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="法定第二计量单位" prop="unit2">
            <el-select v-model="form.unit2" placeholder="法定第二计量单位">
              <el-option v-for="(itme,index) in unit_code" :key="index" :label="itme.label" :value="itme.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="毛重（KG）" prop="gross_weight">
            <el-input v-model="form.gross_weight" maxlength="50" />
          </el-form-item>
        </el-col>
        <!--                <el-col :span="8">-->
        <!--                  <el-form-item label="计量数量" prop="qty">-->
        <!--                    <el-input v-model="form.qty" maxlength="50" />-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="法定计量数量" prop="qty1">
            <el-input v-model="form.qty1" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="法定第二计量数量" prop="qty2">
            <el-input v-model="form.qty2" maxlength="50" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="净重（KG）" prop="net_weight">
            <el-input v-model="form.net_weight" maxlength="50" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="top: 30px;margin-bottom: 30px;text-align:center;">
        <el-col :span="24">
          <el-button type="primary" size="medium" @click="onSubmit">提 交</el-button>
          <el-button size="medium" @click="close()">取 消</el-button>
        </el-col>
      </el-row></el-form>
  </el-dialog>
</template>
<script>
import { accountEdit } from '@/api/account'
export default {
  name: 'Edit',
  props: {
    open: {
      type: Boolean
    },
    form: {
      type: Object
    }
  },
  data() {
    return {
      currency: this.selectJson(1),
      tradeCountry: this.selectJson(2),
      unit_code: this.selectJson(3)
    }
  },
  methods: {
    /** 修改提交 */
    onSubmit() {
      const that = this
      accountEdit({ form: this.form, type: 2 }).then(response => {
        if (response.code === 10000) {
          that.$message.success(response.message)
          this.$parent.getList()
          this.$emit('update:open', false)
        } else {
          that.$message.error(response.message)
        }
      })
    },
    close() {
      this.$emit('update:open', false)
    }
  }
}
</script>

<style>
.el-col-8 .el-input__inner {
  width: 90%;
}
.el-select {
    display: inline-block;
    position: relative;
    width: 100%;
}
.el-input__suffix {
    position: absolute;
    height: 100%;
    right: 24px;
    top: 0;
    text-align: center;
    color: #C0C4CC;
    -webkit-transition: all 0.3s;
    transition: all 0.3s;
    pointer-events: none;
}
</style>
